<?php

class TestLogin{

	function handleFakeLogin($steamID=""){
		$DB = new DB();
		$User = new User();
		$Login = new Login();
		$con = $DB->conDB();

		// identity is something like: http://steamcommunity.com/openid/id/76561197994761333
		// we only care about the unique account ID at the end of the URL.
		$TestUser = new TestUser();
		if($steamID == ""){
			$steamID = $TestUser->getRandomSteamID();
			
		}
		
		//echo $steamID;
		//setcookie("login[steamID]", $steamID, time()+36000);

		// Check User already in DB

		// if first login generate Stats
		$firstLoginModal = "";
		if(!$User->userAlreadyInDB($steamID)){
			// neuen User eintragen und hash cookie setzen
			$User->insertNewUser($steamID);
			
			$Login->insertFirstStatsOfUser($steamID);
			$firstLoginModal = "?firstLogin=1";
			//header('Location: ' . HOME_PATH.$firstLoginModal);
			$url = HOME_PATH.$firstLoginModal;
		}
		else{
			$User->updateUser($steamID);
			//header('Location: ' . HOME_PATH);
			$url = HOME_PATH;
		}
		$ret['url'] = $url;
		$ret['status'] = true;
		$ret['steamID'] = $steamID;
		return $ret;
	}
}

?>